package huawei;

/**
 * linux发型版的数量
 */
public class Q132 {



    public static void main(String[] args) {
        int[][] g = {
                {1, 1, 0, 0},
                {1 ,1 ,1 ,0},
                {0, 1, 1, 0},
                {0, 0 ,0, 1}
        }    ;

        boolean[] visited = new boolean[g.length];

        int cnt = 0;
        for (int i = 0; i < g.length; i++) {
            cnt = Math.max(dfs(i, g, visited), cnt);
        }

        System.out.println(cnt);
    }

    private static int dfs(int i, int[][] g, boolean[] visited) {
        if (visited[i]) {
            return 0;
        }

        int count = 1;
        visited[i] = true;
        for (int j = 0; j < g.length; j++) {
            if (g[i][j] == 1) {
                count += dfs(j, g, visited);
            }
        }

        return count;
    }
}
